# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from typing import List
from fastapi import APIRouter, Request, Depends
from hypertext import R, PagingResult, response_json
from apps.api.schemas.apply import video_schema as schema
from apps.api.service.apply.video_service import VideoGenService
from apps.api.service.apply.video_service import VideoBasicService

router = APIRouter(prefix="/video", tags=["AI视频接口"])


@router.post("/generate", summary="视频生成")
@response_json
async def generate(request: Request, params: schema.VideoGenerateIn):
    user_id: int = int(request.state.user_id)
    return await VideoGenService(request, user_id, params).generate()


@router.get("/config", summary="视频配置", response_model=R[schema.VideoConfigVo])
@response_json
async def config(request: Request, params: schema.VideoConfigIn = Depends()):
    user_id: int = int(request.state.user_id)
    return await VideoBasicService.config(user_id, params.engine)


@router.get("/record", summary="视频记录列表", response_model=R[PagingResult[schema.VideoRecordsVo]])
@response_json
async def record(request: Request, params: schema.VideoRecordSearchIn = Depends()):
    user_id: int = int(request.state.user_id)
    return await VideoBasicService.record(user_id, params)


@router.post("/detection", summary="视频记录检测", response_model=R[List[schema.VideoRecordsVo]])
@response_json
async def detection(request: Request, params: schema.VideoRecordDetectionIn):
    user_id: int = int(request.state.user_id)
    return await VideoBasicService.detection(user_id, params.ids)


@router.post("/delete", summary="视频记录删除", response_model=R)
@response_json
async def delete(request: Request, params: schema.VideoRecordCodeIn):
    user_id: int = int(request.state.user_id)
    return await VideoBasicService.delete(user_id, params.code)


@router.post("/square", summary="视频记录公开")
@response_json
async def square(request: Request, params: schema.VideoRecordCodeIn):
    user_id: int = int(request.state.user_id)
    return await VideoBasicService.square(user_id, params.code)


@router.post("/collect", summary="视频记录收藏")
@response_json
async def collect(request: Request, params: schema.VideoRecordCodeIn):
    user_id: int = int(request.state.user_id)
    return await VideoBasicService.collect(user_id, params.code)
